/*
 * @Author       : Joel
 * @Date         : 2025-04-01 14:20:31
 * @LastEditors: Joel
 * @LastEditTime: 2025-04-13 09:54:52
 * @FilePath: /smart-cupping2/usr/src/main.c
 * @Description  :
 * Copyright(C)2025 YiJiaLink, All Rights Reserved.
 * 2025-04-01 14:20:31
 */

#include <stdio.h>
#include "main.h"
#include "SEGGER_RTT.h"
#include "BAT32G137.h"
#include "userdefine.h"
#include "sci.h"
#include "intp.h"
#include "ssd1315oled.h"

/***********************************************************************************************************************
Global variables and functions
***********************************************************************************************************************/
extern volatile uint32_t g_ticks;

uint8_t mtx_buf[] = {0xA5, 0x5A, 0xCC, 0x33, 0x3C, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};

int main()
{
  uint32_t msCnt; // count value of 1ms

  //-----------------------------------------------------------------------
  // Systick setting
  //-----------------------------------------------------------------------
  SystemCoreClockUpdate();
  msCnt = SystemCoreClock / 1000;
  SysTick_Config(msCnt);
  /* rtt初始化打印 */
  SEGGER_RTT_Init();
  /* 输出控制 */
  struct ctrl_func *ctrl_set = ctrl_driver_init();
  ctrl_set->device_init();
  ctrl_set->ctrl_run(PWR_CTRL, 1);
  printf("\n\r("__DATE__
         " - " __TIME__ ")");
  printf("\r\nFirmware_version = %d\r\n", (int)UPDATE_VERSION);
  ctrl_set->ctrl_run(OLED_RES, 0);
  delayMS(1000);
  ctrl_set->ctrl_run(OLED_RES, 1);
  delayMS(10);
  oled_test();
 
  while (1)
  {

    printf("Main_loop\r\n");

   
    delayMS(1000);

    // SPI21_MasterSend(mtx_buf, sizeof(mtx_buf));
  }
}
